******************************************************************************************
***CLASSROOMS OR CRACKDOWNS? HOW VIOLENCE AFFECTS SECURITY POLICY PREFERENCES IN MEXICO***
***Authors: Sarah Berens, Ana I. López García, Barry Maydom*******************************
******************************************************************************************

*************
**ANALYSIS***
*************
*1.DV
*2. Regression 
*3 Subgroup analysis
***3.1 Crime
***3.2 Fear
***3.3 State abuse 
*4. Sensitivity Tests 
***4.1 Self protection groups 
***4.2 Payment of bribes to police

use "Data ready E5.dta", clear 
*****************************************************
*1.DV

*DEPENDENT VARIABLE DISTRIBUTION 
tab E5_crime_measures 

********************************************************
*2.MAIN EFFECTS
*Anova 
anova E5_crime_measures i.E5_vign1##i.E5_vign2
margins r.E5_vign1##r.E5_vign2, contrast(pveffects nowald) post

anova E5_crime_measures i.E5_vign1##i.E5_vign2
margins r.E5_vign1, contrast(pveffects nowald) post

anova E5_crime_measures i.E5_vign1##i.E5_vign2
margins r.E5_vign1, contrast(pveffects nowald) post

anova E5_crime_measures i.E5_vign1##i.E5_vign2
margins r.E5_vign2, contrast(pveffects nowald) post

anova E5_crime_measures i.E5_vign1##i.E5_vign2
margins r.E5_vign2, contrast(pveffects nowald) post


************************
**3. SUBGROUP ANALYSIS**
************************
*3.1 Violent crime victims
*3.2 Fear of crime
**3.2.1 Unsafe state
**3.2.2 Changed behaviour due to fear of crime 
*3.3 State abuse


****************************
*3.1 VIOLENT CRIME VICTIMS

*E5. Subgroup analysis 

*VIOLENT CRIME - DV: support for increased policing
anova E5_crime_measures i.E5_vign1##i.E5_vign2##i.violence_victim
contrast violence_victim, pveffects nowald
pwcompare violence_victim, pveffects

*Nonvictims vs violent crime victims 
*Anova 
anova E5_crime_measures i.E5_vign1##i.E5_vign2##i.violence_victim
margins r.E5_vign2#violence_victim, contrast(nowald pveffects) post

anova E5_crime_measures i.E5_vign1##i.E5_vign2##i.violence_victim
mtable, at(E5_vign2 =(0 (1) 5) violence_victim = (0 (1) 2)) post	
mlincom 5 - 2, stat(est p)
mlincom 8 - 2, stat(est p)
mlincom 11 - 2, stat(est p)

*Education
mlincom (5 - 2) - (4 - 1), stat(est p)
mlincom (5 - 2) - (6 - 3), stat(est p)

*Employment
mlincom (8 - 2) - (7 - 1), stat(est p)
mlincom (8 - 2) - (9 - 3), stat(est p)

*Prison
mlincom 10 - 1, stat(est p)
mlincom 11 - 2, stat(est p)
mlincom 12 - 3, stat(est p)
mlincom (12 - 3) - (10 - 1), stat(est p)
mlincom (12 - 3) - (11 - 2), stat(est p)

*Harsher sentences
mlincom 13 - 1, stat(est p)
mlincom 14 - 2, stat(est p)
mlincom 15 - 3, stat(est p)
mlincom (13 - 1) - (14 - 2), stat(est p)
mlincom (13 - 1) - (15 - 3), stat(est p)

*Policing
mlincom 16 - 1, stat(est p)
mlincom 17 - 2, stat(est p)
mlincom 18 - 3, stat(est p)
mlincom (16 - 1) - (17 - 2), stat(est p)
mlincom (16 - 1) - (18 - 3), stat(est p)
mlincom (17 - 2) - (18 - 3), stat(est p)


*****************************************
*3.2 FEAR OF CRIME

*3.2.1 FEAR OF CRIME - Unsafe state******

*E5. Subgroup analysis 
ttest E5_crime_measures, by(unsafe_state)
anova E5_crime_measures i.E5_vign1##i.E5_vign2##i.unsafe_state
contrast unsafe_state, pveffects nowald
pwcompare unsafe_state, pveffects

* Changed behaviour due to fear 
*Anova 
anova E5_crime_measures i.E5_vign1##i.E5_vign2##i.unsafe_state
margins r.E5_vign2#unsafe_state, contrast(nowald pveffects) post


anova E5_crime_measures i.E5_vign1##i.E5_vign2##i.unsafe_state
mtable, at(E5_vign2 =(0 (1) 5) unsafe_state = (0 (1) 1)) post
	
*Employment
mlincom 5 - 1, stat(est p)
mlincom 6 - 2, stat(est p)
mlincom (5 - 1) - (6 - 2), stat(est p)

*Policing
mlincom 11 - 1, stat(est p)
mlincom 12 - 2, stat(est p)
mlincom (11 - 1) - (12 - 2), stat(est p)


********************************************************
*3.2 FEAR OF CRIME

*3.2.1. FEAR OF CRIME - Changed behaviour due to fear of crime****

*E5. Subgroup analysis 
ttest E5_crime_measures, by(crime_fear)
anova E5_crime_measures i.E5_vign1##i.E5_vign2##i.crime_fear
contrast crime_fear, pveffects nowald
pwcompare crime_fear, pveffects

* Changed behaviour due to fear 
*Anova 
anova E5_crime_measures i.E5_vign1##i.E5_vign2##i.crime_fear
margins r.E5_vign2#crime_fear, contrast(nowald pveffects) post


**************************************************************************

*3.3 STATE ABUSE*

*E5. Subgroup analysis 
ttest E5_crime_measures, by(police_abuse)
anova E5_crime_measures i.E5_vign1##i.E5_vign2##i.police_abuse
contrast police_abuse, pveffects nowald
pwcompare police_abuse, pveffects

*Anova 
anova E5_crime_measures i.E5_vign1##i.E5_vign2##i.police_abuse
margins r.E5_vign2#police_abuse, contrast(nowald pveffects) post

anova E5_crime_measures i.E5_vign1##i.E5_vign2##i.police_abuse
mtable, at(E5_vign2 =(0 (1) 5) police_abuse = (0 (1) 1)) post	
mlincom 3 - 1, stat(est p)
mlincom 4 - 2, stat(est p)
mlincom (4 - 2) - (3 - 1), stat(est p)

******************
*3.3 STATE ABUSE + CRIME VICTIMISATION
*E5. Subgroup analysis 
anova E5_crime_measures i.E5_vign1##i.E5_vign2##i.crime_state
contrast crime_state, pveffects nowald
pwcompare crime_state, pveffects

*Anova 
anova E5_crime_measures i.E5_vign1##i.E5_vign2##i.crime_state

*Interaction contrasts
contrast E5_vign2#r.crime_state

*Simple effects
contrast E5_vign2@crime_state

*Simple contrasts 
contrast r.E5_vign2@0.crime_state, nowald pveffects
contrast r.E5_vign2@1.crime_state, nowald pveffects
contrast r.E5_vign2@2.crime_state, nowald pveffects
contrast r.E5_vign2@3.crime_state, nowald pveffects

anova E5_crime_measures i.E5_vign1##i.E5_vign2##i.crime_state
mtable, at(E5_vign2 =(0 (1) 5) crime_state = (0 (1) 3)) post	

*Education 
mlincom 6 - 2, stat(est p)
mlincom (6 - 2) - (5 -1), stat(est p)
mlincom 7 - 3, stat(est p)
mlincom (7 - 3) - (5 -1), stat(est p)

*Employment
mlincom 11 - 3, stat(est p)
mlincom (11 - 3) - (9 -1), stat(est p)

*Prison 
mlincom 16 - 4, stat(est p)
mlincom (16 - 4) - (13 -1), stat(est p)


******************************************************
*4. SENSITIVITY TESTS
*4.1. Self protection groups
*4.2. Payment of bribes to police

**************************************
*4.1 Self protection groups

*E5. Subgroup analysis 
ttest E5_crime_measures, by(vigilantes_neigh)
anova E5_crime_measures i.E5_vign1##i.E5_vign2##i.vigilantes_neigh
contrast vigilantes_neigh, pveffects nowald
pwcompare vigilantes_neigh, pveffects

*Anova 
anova E5_crime_measures i.E5_vign1##i.E5_vign2##i.vigilantes_neigh

*Interaction contrasts
contrast E5_vign1#r.vigilantes_neigh
contrast E5_vign2#r.vigilantes_neigh

*Simple effects
contrast E5_vign1@vigilantes_neigh
contrast E5_vign2@vigilantes_neigh

*Simple contrasts (grand mean)
contrast r.E5_vign1@0.vigilantes_neigh, nowald pveffects
contrast r.E5_vign1@1.vigilantes_neigh, nowald pveffects

*Simple contrasts (grand mean)
contrast r.E5_vign2@0.vigilantes_neigh, nowald pveffects
contrast r.E5_vign2@1.vigilantes_neigh, nowald pveffects

*Simple contrasts (control group)
contrast r.E5_vign1@0.vigilantes_neigh, nowald pveffects
contrast r.E5_vign1@1.vigilantes_neigh, nowald pveffects

*Simple contrasts (control group)
contrast r.E5_vign2@0.vigilantes_neigh, nowald pveffects
contrast r.E5_vign2@1.vigilantes_neigh, nowald pveffects

anova E5_crime_measures i.E5_vign1##i.E5_vign2##i.vigilantes_neigh
mtable, at(E5_vign2 =(0 (1) 5) vigilantes_neigh = (0 (1) 1)) post	
*Education
mlincom 3 - 1, stat(est p)
mlincom 4 - 2, stat(est p)
mlincom (4 - 2) - (3 - 1) , stat(est p)


***************************************************************
*4.2 POLICE BRIBE (proxy for state abuse)

*E5. Subgroup analysis 
*Paid a police bribe  
ttest E5_crime_measures, by(police_bribe)
anova E5_crime_measures i.E5_vign1##i.E5_vign2##i.police_bribe
contrast police_bribe, pveffects nowald
pwcompare police_bribe, pveffects

anova E5_crime_measures i.E5_vign1##i.E5_vign2##i.police_bribe

*Interaction contrasts
contrast E5_vign2#r.police_bribe

*Simple effects
contrast E5_vign2@police_bribe

*Simple contrasts 
contrast r.E5_vign2@0.police_bribe, nowald pveffects
contrast r.E5_vign2@1.police_bribe, nowald pveffects

anova E5_crime_measures i.E5_vign1##i.E5_vign2##i.police_bribe
mtable, at(E5_vign2 =(0 (1) 5) police_bribe = (0 (1) 1)) post	
mlincom 3 - 1, stat(est p)
mlincom 4 - 2, stat(est p)
mlincom (4 - 2) - (3 - 1), stat(est p)
mlincom 5 - 1, stat(est p)
mlincom 6 - 2, stat(est p)
mlincom (6 - 2) - (5 - 1), stat(est p)
